package com.sheng.project.test.sort;

/**
 * 冒泡排序：相邻的两个元素之间进行比较
 *
 * @author liusheng
 * @date 2022/08/19
 */
public class BubbleSort {

    public static void bubble(int[] ints) {
        int length = ints.length;
        for (int i = 0; i < length; i++) {
            for (int j = 1; j < length; j++) {
                if (ints[j - 1] > ints[j]) {
                    int t = ints[j - 1];
                    ints[j - 1] = ints[j];
                    ints[j] = t;
                }
            }
        }
    }
}
